package com.yanqu.road.server.cmd.activity.flowerstudy;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FlowerStudyProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.flowerstudy.CrossFlowerStudyMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_FLOWER_STUDY_EXAM_GET_ROOM_DETAIL,desc = "主动请求同步房间详细")
public class CrossFlowerStudyGetRoomDetailCmd extends CrossCommand {

    private int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        FlowerStudyProto.FlowerStudyExamRoomNewestDataReq req = FlowerStudyProto.FlowerStudyExamRoomNewestDataReq.parseFrom(packet.getBytes());
        activityId = req.getActivityId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        FlowerStudyProto.FlowerStudyExamRoomNewestDataResp.Builder roomDetail = CrossFlowerStudyMgr.getRoomDetail(activityId, packet.getPlayerId(), (int) serverId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(ClientProtocol.U_FLOWER_STUDY_GET_ROOM_DETAIL,roomDetail);
        MessageHelper.sendPacket(serverId,packet.getPlayerId(),pbMsg);
    }

    @Override
    public void sendData() {

    }
}
